﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Threading;
using System.Collections.ObjectModel;

namespace gui {

    /// <summary>
    /// Static class that holds a collection of algorithms
    /// </summary>
    public class AlgorithmSelectListInfo : DependencyObject {

        public static AlgorithmSelectListInfo Instance;
        public static Dispatcher _Dispatcher { get; set; }

        public static DependencyProperty AlgorithmsListProperty = DependencyProperty.Register("AlgorithmsList", typeof(ObservableCollection<AlgorithmItem>), typeof(AlgorithmSelectListInfo));

        static AlgorithmSelectListInfo() {
            Instance = new AlgorithmSelectListInfo();
        }

        public ObservableCollection<AlgorithmItem> AlgorithmsList {
            get { return (ObservableCollection<AlgorithmItem>)GetValue(AlgorithmsListProperty); }
            set { SetValue(AlgorithmsListProperty, value); }
        }

        public static void Clear() {
            if (_Dispatcher != null) {
                _Dispatcher.BeginInvoke(
                    DispatcherPriority.Send,
                    new Action(delegate() {
                        Instance.AlgorithmsList.Clear();
                }));
            }
        }
    }
}
